import { ReceiveMessageType } from '/@/config/DeclareGlobal';
import Vector3 from '/@/core/bean/Vector3';
import ReceiveMessage from '/@/core/communication/ReceiveMessage';

interface SelectedInfo {
  type: ReceiveMessageType.SelectedInfo;
  data: {
    name: string;
    position: Vector3;
    rotation: Vector3;
    scale: Vector3;
  };
}

//选中物体时会发送这个物体的所有信息
export const selectedInfo = (callback: (data: SelectedInfo) => void) => {
  ReceiveMessage.addListener(ReceiveMessageType.SelectedInfo, (e: MessageEvent) => {
    callback(e.data as SelectedInfo);
  });
};

//unity初始化完成时会发送一个消息告知已经初始化完成
export const Initialized = (callback: () => void) => {
  ReceiveMessage.addListener(ReceiveMessageType.Initialized, () => callback());
};
